package org.example;

import org.example.Enum.ActionEnum;
import org.example.Enum.Conditions;
import org.example.Enum.PanelState;
import org.example.Events.Events;

/**
 * @program: B2_exper4
 * @description:
 * @author: hlt
 * @create: 2023-11-05 08:48
 **/
public class StateTranslation {
    // 当前状态
    private PanelState currentState;

    // 下一个状态
    private PanelState nextState;

    // 到达下一个状态时需要达到的前提条件
    private Conditions condition;

    // 相应的动作
    private ActionEnum action;

    // 触发事件
    private Events event;

    public PanelState getCurrentState(){
        return currentState;
    }

    /**
     * 在CurrentState下，如果发生了action动作并且满足前提条件Condition，会使当前状态转换到nextState，并触发Events动作
     * @return
     */
    public PanelState getNextState(){
        return nextState;
    }

    public Events getEvent(){
        return event;
    }

    public ActionEnum getAction(){
        return action;
    }

    public Conditions getCondition(){
        return condition;
    }

    // 链式初始化对象
    public StateTranslation source(PanelState state){
        // 原始的状态
        this.currentState = state;
        return this;
    }
    public StateTranslation when(ActionEnum action){
        // 当发生action时
        this.action = action;
        return this;
    }

    public StateTranslation Condition(Conditions condition){
        // 设置此时已经达到的前提条件
        this.condition = condition;
        return this;
    }
    public StateTranslation targets(PanelState nextState){
        // 目标，下一个状态
        this.nextState = nextState;
        return this;
    }
    public StateTranslation how(Events event){
        this.event = event;
        return this;
    }
}
